<?php

namespace App\Admin\Controllers;

use App\Models\Client;
use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\HasResourceActions;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Layout\Content;
use Encore\Admin\Show;
use Encore\Admin\Facades\Admin;
use Request;
class FeeController extends Controller
{
    use HasResourceActions;

    /**
     * Index interface.
     *
     * @param Content $content
     * @return Content
     */
    public function index(Content $content)
    {
        $fee_verify = config('charge.verify');

        return Admin::content(function (Content $content) use($fee_verify) {

            $content->header('收费管理');
            $content->description('收费管理');

            $articleView = view('admin.fee',compact('fee_verify'))->render();
            $content->row($articleView);
            admin_toastr('提示','success');
        });
    }

    //改变配置文件的配置
    public function changeConfig(){
        $fee_type = config('charge.type');
        $input_data = Request::all();
        $fee_verify = [
            1 => $input_data['1'],
            2 => $input_data['2'],
            3 => $input_data['3'],
            4 => $input_data['4'],
            5 => $input_data['5'],
            6 => $input_data['6'],
        ];
        $write_data = [
            'verify' => $fee_verify,
            'type' => $fee_type
        ];
        $path = '../config/charge_copy.php';
        $str = '<?php return ';
        $str .= var_export($write_data,true);//数组转字符串
        $str .= ';';
        file_put_contents($path,$str);
        return ['info'=>'成功'];
    }


}
